Skip to content

Feat/log#7

Merged
kooksee merged 16 commits into
mainfrom
feat/log
Jun 3, 2026
Merged

Feat/log#7
kooksee merged 16 commits into
mainfrom
feat/log

Conversation

@kooksee
Copy link
Copy Markdown
Contributor

@kooksee kooksee commented May 31, 2026

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the log subcommand to directly read log files from the CLI, bypassing the daemon socket. It introduces new features such as following logs in real-time (-f), specifying the number of lines to display (-n), and viewing daemon or all service logs. Feedback on these changes highlights a few critical issues: a race condition in the follow loop that can cause duplicate log output, the unintended omission of empty lines in the output, incorrect handling of -n 0 line counts, and a lack of validation for invalid -n arguments.

Comment thread tools/ziginit/journal.zig Outdated
Comment thread tools/ziginit/journal.zig Outdated
Comment thread tools/ziginit/journal.zig
Comment thread tools/ziginit/main.zig
kooksee

This comment was marked as outdated.

@kooksee
Copy link
Copy Markdown
Contributor Author

kooksee commented May 31, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the logging system in ziginit to allow the CLI to directly read log files instead of querying the daemon via Unix sockets. This change enables a new follow mode (-f), custom line counts (-n), and direct viewing of daemon logs. The feedback highlights a potential silent data loss bug in followOutput for log lines exceeding 4KB, dangerous silent path truncations in path-building functions that should panic instead, and an inefficiency in followFiles where files are repeatedly opened and closed in the polling loop.

Comment thread tools/ziginit/journal.zig
Comment thread tools/ziginit/config.zig
Comment thread tools/ziginit/config.zig
Comment thread tools/ziginit/journal.zig Outdated
@kooksee
Copy link
Copy Markdown
Contributor Author

kooksee commented May 31, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the log command in ziginit to directly read log files from the CLI, bypassing the daemon socket. It introduces new features such as follow mode (-f), custom line counts (-n), and unified logging (--all), along with comprehensive E2E tests. The review feedback highlights a potential data loss bug in the carry buffer handling of journal.zig when incoming data exceeds available space, an unsafe @ptrCast for sentinel-terminated pointers, and a compatibility issue in the Go tests due to the use of the min built-in introduced in Go 1.21.

Comment thread tools/ziginit/journal.zig Outdated
Comment thread tools/ziginit/journal.zig Outdated
Comment thread tools/ziginit/tests/e2e_test.go
Copy link
Copy Markdown
Contributor Author

@kooksee kooksee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查摘要

文件覆盖

文件 已审查 问题数
.github/instructions/ziginit.instructions.md 0
.github/workflows/release-ziginit.yml 0
tools/ziginit/README.md 0
tools/ziginit/config.zig 0
tools/ziginit/docs/log-improvements.md 0
tools/ziginit/helpers.zig 0
tools/ziginit/journal.zig 1
tools/ziginit/logrotate.zig 0
tools/ziginit/main.zig 0
tools/ziginit/posix.zig 0
tools/ziginit/protocol.zig 1
tools/ziginit/server.zig 0
tools/ziginit/service.zig 0
tools/ziginit/tests/e2e_test.go 0
tools/ziginit/tests/helpers_test.go 0

总计: 已审查 15/15 个文件

问题统计

严重程度 数量
🔴 关键 1
🟠 高 0
🟡 中 0
🟢 普通 1
🔵 低 0

关键风险

  1. tools/ziginit/journal.zigfollowOutput 在 carry 非空且新 chunk 无换行时,若 data.len > avail 会静默丢弃 remainder,导致 follow 输出丢日志。

非阻断建议处置

建议 分类 处置 说明
协议注释与实现保持一致 [CONS] accepted 已记录,建议修正文档注释为 2-byte msg_len。

Reviewer 对齐摘要

外部评论 分类 处置 理由
3330317269/7270/7271/7273 [LOGI]/[RBST] accepted 对应修复已体现在当前代码。
3330455951/5954/5955 [RBST]/[PERF] accepted 路径溢出防护与 follow FD 优化已落地。
3330472251 [LOGI] deferred 当前实现仍可在 data.len > avail 时丢弃数据,需继续修复。
3330472254 [PRAC] rejected 风格建议,现实现不构成功能缺陷。
3330472256 [CPT] rejected 仓库 Go 版本 1.25.3,min 可用。

结论

⚠️ 需要修改

存在 1 个阻断性逻辑问题(日志跟随模式可能静默丢数据),建议修复后再通过。

(本次使用降级通道提交:gh pr review --comment 等价的 PR review comment,因当前环境无 codereview MCP 工具)

Comment thread tools/ziginit/journal.zig Outdated
Comment thread tools/ziginit/protocol.zig Outdated
@kooksee kooksee merged commit 0f0df08 into main Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant